#include<stdio.h>
#include<string.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/wait.h>
#define NAME "save.c"
void change(char* buf);
int main()
{
	int flag;
	int fd;
	int child;
	int pid;
	int num;
	char buf[100]="";
	if(fd=open(NAME,O_CREAT|O_RDWR,0666)==-1)
	{
		perror("fail to open the file\n");
		return -1;
	}
//	printf("fd = %d\n",fd);
	//while(1)
	{
		printf("Please input the Letter\n" );
		scanf("%s",buf);
	//	setbuf(stdin,NULL);
		//ichange(buf);
	//	if(buf[0]=='#')
		{
	//		printf("exit\n");
	//		break;
		}
		write(fd,buf,strlen(buf));
	//	memset(buf,0,100);
	}
	close(fd);
	/*
	pid=vfork(); 
	if(pid==0 )
	{
		execl( "./function" ,"./function" ,NULL);
		printf("Fail to call execl()\n");
	}
	else
	{
		wait(&child);
	}*/
	return 0;
}
void change(char* buf)
{
	for(int i=0;i<100;i++)
	if((buf[i]>='a' )&&(buf[i]<='z'))
	*(buf+i)=*(buf+i)-32;
}
